/**
 * Created by Demon-pro on 2015/6/28.
 */
var Heat = function () {
    function buttonHandle() {
        $("#nextPage").on("click", function () {
            location.href = basePath + "mill/pipe?menuId=39"
        });
    }

    function wizardHandle() {

        function btnHandle(tab, navigation, index) {
            var $total = navigation.find('li').length;
            var $current = index + 1;
            if ($current == $total) {
                $("#pre").show();
                $("#next").hide();
                $("#validate").hide();
                $("#nextPage").show();
            } else {
                $("#pre").hide();
                $("#next").show();
                $("#validate").show();
                $("#nextPage").hide();
            }
        }

        function checkE59() {
            var accept = true;
            Metronic.blockUI({
                boxed: true,
                message: "校验中..."
            });
            $.ajax({
                url: basePath + "mill/heat/checkE59",
                dataType: "json",
                async: false,
                type: "post",
                success: function (data) {
                    if (!data) {
                        toast.error("请重新设定锅炉一次风率或选择其他型号");
                        accept = false;
                    }
                    Metronic.unblockUI();
                }
            });
            return accept;
        }

        $(".form-wizard").bootstrapWizard({
            'nextSelector': "#next",
            'previousSelector': "#pre",
            onInit: function (tab, nav, index) {
                $("#pre").hide();
                $("#nextPage").hide();
            },
            onTabShow: function (tab, navigation, index) {
                var $total = navigation.find('li').length;
                var $current = index + 1;
                var $percent = ($current / $total) * 100;
                $('.form-wizard').find('.bar').css({width: $percent + '%'});
                Metronic.scrollTo($('.active'))
            },
            onNext: function (tab, navigation, index) {
                btnHandle(tab, navigation, index);
            },
            onPrevious: function (tab, navigation, index) {
                btnHandle(tab, navigation, index);
            }
        });
    }

    var checkIsNotCalculate = function () {
        var flag = true;
        $("input").each(function () {
            if ($(this).val() == "") {
                flag = true;
            } else {
                flag = false;
            }
        });
        return flag;
    };

    var init = function () {
    };

    return {
        init: function () {
            $("#tab1")
            buttonHandle();
            wizardHandle();
            $("#verification").on("click", function () {
                $("#Y").hide();
                $("#N").hide();
                $("#modal").modal("show")
                if ($("#validateType").val() == "合格") {
                    $("#Y").show();
                } else {
                    $("#N").show();
                }
            })
        },
        stepCheck: function (state) {
            if (state == 1) {
                $("#next").show();
                $("#pre").hide();
                $("#nextPage").hide();
                $("#validate").show();
            } else {
                $("#pre").show();
                $("#nextPage").show();
                $("#next").hide();
                $("#validate").hide();
            }
        }
    }
}();